
const a = '123456789';
const b = '11111111111111111111111111';
 
function add(a, b) {
    var temp = 0;
    var res = ""
    a = a.split("");
    b = b.split("");
    while (a.length || b.length || temp) {
        // ~~表示两次取反的自然结果，保持原值，通过计算得到的值都是number类型
        temp += ~~(a.pop()) + ~~(b.pop());
        res = (temp % 10) + res;
        // 相当于temp = temp > 9 ? 1: 0
        temp = temp > 9
        console.log(temp);
    }
    return res
}
 
console.log(add(a, b));